﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BLL;
using Model;

namespace 超市收银台
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F2)
            {
                txtSearch.Focus();
            }
        }
        private void Search()
        {
            MessageBox.Show("结算成功");
        }
        
        private void txtSearch_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F5)
            {
                Search();
            }
            if (txtSearch != null) 
            {
                if (e.KeyCode == Keys.Enter)
                {
                    btnSearch_Click(null, null);                    
                }
            }
        }
        private List<GoodsInfo> buygoods = new List<GoodsInfo>();
        private void bangdin()
        {
            dgvInfo.DataSource = new BindingList<GoodsInfo>(buygoods);
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
                GoodsService gs = new GoodsService();
                List<GoodsInfo> add =  gs.GService(txtSearch.Text);
                BuyGoodsInfo a = new BuyGoodsInfo();
            if (add.Count == 0)
            {
                MessageBox.Show("商品码错误");
            }
            else
            {
            }

            bangdin();

            txtSearch.Text = ""; 
        }
    }
}
